package com.demo.system.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.demo.common.entity.ChatRoomMember;
import com.demo.common.entity.vo.ChatRoomMemberVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 聊天室成员表(ChatRoomMember)表数据库访问层
 *
 * @author why
 * @since 2025-09-23 10:12:42
 */
@Mapper
public interface ChatRoomMemberMapper extends BaseMapper<ChatRoomMember> {

    @Select("SELECT b.id AS user_id,b.username,b.gender,b.age,b.avatar,b.address, c.id as room_id,c.room_name,c.room_type,c.room_description,c.avatar," +
            "c.max_members,c.is_active,c.creator_id, c.avatar AS room_avatar,a.role,a.nickname,a.join_time,a.is_muted FROM `chat_room_member` a " +
            "LEFT JOIN `user` b ON a.user_id=b.id LEFT JOIN chat_room c ON a.room_id=c.id  ${ew.customSqlSegment}")
    List<ChatRoomMemberVO> listRoomByUserId(@Param("ew") Wrapper<ChatRoomMemberVO> queryWrapper);

}

